﻿module Sustainalytics.Screening {

    import Common = Sustainalytics.Common;
    import SearchBox = Sustainalytics.SearchBox;


    export interface IScreeningToolSearchBoxService {
        // Search for items given a term and paging options
       // Search(searchData: any, skip: number, take: number): ng.IHttpPromise<any[]>;
    }


    export class CriteriaSearchBoxServiceAdapter implements IScreeningToolSearchBoxService {
        private _http: ng.IHttpService;
        private _q:ng.IQService;
        public constructor($http) {
            this._http = $http;
            
        }

        public Search(): ng.IHttpPromise<any[]> {
            if (navigator.appVersion.indexOf("MSIE 9.") != -1 || navigator.appVersion.indexOf("MSIE 10") != -1) { //todo right now is just a hack and a hard-coded version if it changes it should reference the link built in screening tool factory
                var lstPromise: ng.IHttpPromise<any[]> = this._http.get("screeningtoolserv/api/v1/criterialevel1/undefined/criterialevel2/undefined/templatecriteria?returnAllBaseCriteria=true"); 
                return lstPromise;

            }
            var lstPromise: ng.IHttpPromise<any[]> = this._http.get("");
           return lstPromise;
           
            
        }
    }


    var mod = angular.module(screeningToolModuleName);

    mod.service('CriteriaSearchBoxServiceAdapter', ['$http', CriteriaSearchBoxServiceAdapter]);

}